﻿using DataShow.codeModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace DataShow.codeDAL
{
    public class ForecastProcess
    {
        #region 构造函数
        SqlHelper sqlhelper;
        public ForecastProcess()
        {
            sqlhelper = new SqlHelper();
        } 
        #endregion

        #region 搜索
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pagesize">页大小</param>
        /// <param name="pageindex">页码</param>
        /// <param name="condition">条件</param>
        /// <returns>DataTable</returns>
        public DataTable Search(string tableName, int pagesize, int pageindex, string condition)
        {
            return new Common().Search(tableName, pagesize, pageindex, condition, "*","date,type");
        } 
        #endregion

        

        #region 添加一条预报员输入数据
        /// <summary>
        /// 添加一条预报员输入数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool AddRecord(UserAddData data)
        {
            string sql = "insert into @tableName values (@date,@clock,@span,@sendpoint,@type,@semitype,@value)";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@tableName",data.TableName),
                new SqlParameter("@clock",data.Clock),
                new SqlParameter("@span",data.Span),
                new SqlParameter("@sendpoint",data.SendPoint),
                new SqlParameter("@type",data.Type),
                new SqlParameter("@semitype",data.Semitype),
                new SqlParameter("@value",data.Value)
            };
            return sqlhelper.ExecuteNonQuery(sql, param) > 0;
        } 
        #endregion

    }
}